Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wingho]IP #196

Open
wants to merge 90 commits into
base: master
Choose a base branch
from
Open

[wingho]IP #196

wants to merge 90 commits into from

Conversation

kum-wh
Copy link

@kum-wh kum-wh commented Sep 2, 2021

No description provided.

wingho2 added 5 commits September 2, 2021 02:57
Change the initial string that printed
…t on bye

Import a Scanner class and add a to that echo input.
…hen list is called

Add a array of size 100 that store string
Add Task class iinstead of just storing the tasks as strings
Copy link

@joshualeeky joshualeeky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments :)

for (int i = 0; i < listIndex; i++) {
System.out.println((i + 1) + ". " + list[i].toString());
}
}else if(echoLower.startsWith("event")){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small issue, I think there should be spaces before "{" and after "}"

Task t = new Deadline(description, deadline);
list[listIndex] = t;
listIndex += 1;
System.out.println("Got it. I've added this task: " + System.lineSeparator() + t.toString() + System.lineSeparator() + "Now you have " + listIndex +" tasks in the list.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are more than 120 characters in this line, maybe you could split it into 2 lines?

Task t = new Event(description, time);
list[listIndex] = t;
listIndex += 1;
System.out.println("Got it. I've added this task: " + System.lineSeparator() + t.toString() + System.lineSeparator() + "Now you have " + listIndex+" tasks in the list.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are more than 120 characters in this line, maybe you could split it into 2 lines?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

Task t = new Todo(description);
list[listIndex] = t;
listIndex += 1;
System.out.println("Got it. I've added this task: " + System.lineSeparator() + t.toString() + System.lineSeparator() + "Now you have " + listIndex +" tasks in the list.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are more than 120 characters in this line, maybe you could split it into 2 lines?

" What can I do for you?\n" +
"____________________________________________________________\n");
Scanner in = new Scanner(System.in);
Task[] list = new Task[100];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe can try using another name for the list? Just to make it clear what is being stored in here.

return description;
}
public String getStatusIcon(){
return(isDone?"X":" ");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could consider using the full if statement.

Copy link

@Yuxinn-J Yuxinn-J left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few issues about coding standard need change

return description;
}
public String getStatusIcon(){
return(isDone?"X":" ");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return(isDone?"X":" ");
return(isDone ? "X" : " ");

}
}else if(echoLower.startsWith("event")){
int startOfTime = echoLower.indexOf("/");
String description = echoLower.substring(6,startOfTime);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to avoid magic number, e.g., 6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to avoid magic numbers, e.g., 6

for(int i = 0; i < listIndex; i ++){
System.out.println((i + 1) + ". " + list[i].toString());
}
}else if(echoLower.equals("done")) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a very small issue of coding standard. Based on Checkstyle, there should be a space before else and after if here.

Suggested change
}else if(echoLower.equals("done")) {
} else if (echoLower.equals("done")) {

Copy link

@ruyian ruyian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall great job, Wingho!

Comment on lines 1 to 9
public class Deadline extends Task{
protected String by;
public Deadline(String description, String by){
super(description);
this.by = by;
}
public String toString(){
return "[D]" + super.toString() + "by: " + by + ")";
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to follow the coding standard where there is a space between the class name and the {. The same goes for methods.

@@ -0,0 +1,10 @@
public class Event extends Task{
protected String time;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to make it a private string to ensure data hiding in encapsulation.

@@ -15,4 +15,7 @@ public String getDescription(){
public String getStatusIcon(){
return(isDone?"X":" ");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the coding standard in leaving spaces.

Comment on lines 7 to 8
public String toString(){
return "[D]" + super.toString() + "by: " + by + ")";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more readable if you add the @OverRide before overriding toString() method.

Comment on lines 27 to 31
}else if(echoLower.equals("list")) {
for(int i = 0; i < listIndex; i ++){
System.out.println((i + 1) + ". ["+ list[i].getStatusIcon() + "] " + list[i].getDescription());
System.out.println((i + 1) + ". " + list[i].toString());
}
}else if(echoLower.equals("done")) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave spaces for the if-else blocks, abiding by the coding standard.

Comment on lines 3 to 7
public Deadline(String description, String by){
super(description);
this.by = by;
}
public String toString(){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to have a blank line in between variables declared and method, as well as between two methods.

wingho2 added 18 commits September 4, 2021 11:59
Improve the naming to be more descriptive of the variable it represent

Use constants to remove the need for magic numbers

Change array into arraylist to prevent overflow of task in the array
…y to set multiple task as done in the same line

Added a interface to listManager to make it easier to know what listMananger does
…n user input

Added a class artbot that use 2D array to create and merge the string to form the shape of letters
Added a file class to interact with txt files
# Conflicts:
#	src/main/java/duke/ListManager.java
Copy link

@rafaelperes rafaelperes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Wing Ho! Nice job here. I hope my comments might help you :)

fileManager.covertStringToTask();
while(isOnline) {
String userInput = in.nextLine().toLowerCase().trim();
if (userInput.startsWith("!")) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps a magic string here? maybe change to a named constant in case you are going to use it somewhere else...

Comment on lines 51 to 60
String[] splitString = s.split(";");
switch (splitString[0]){
case "[T]":
listManager.addTodo(splitString[2], true);
break;
case "[E]":
listManager.addEvent(splitString[2],splitString[3], true);
break;
case"[D]":
listManager.addDeadline(splitString[2],splitString[3], true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does splitString[0], splitString[2], splitString[3] stands for? perhaps declare it giving specific names to improve understandability? e.g. splitString[0] -> taskType?

case"[D]":
listManager.addDeadline(splitString[2],splitString[3], true);
}
if (splitString[1].equals("[X]")){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps change [X] to a constant?

Comment on lines 99 to 102
System.out.println(Logo.dividerWithoutNewLine);
printAddItem(t);
System.out.println(Logo.dividerWithoutNewLine);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps improve understandability by apply the SLAP concept here? e.g a method to print these 3 lines of code?

Comment on lines 109 to 111
System.out.println(Logo.dividerWithoutNewLine);
printAddItem(t);
System.out.println(Logo.dividerWithoutNewLine);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as line 99, repeated code here...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants